package com.kucai.yifaqapp.ui.fragment;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Base64;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;
import com.google.gson.Gson;
import com.kucai.yifaqapp.R;
import com.kucai.yifaqapp.global.HttpAdress;
import com.kucai.yifaqapp.model.network.entity.res.WebSocketMsgBean;
import com.kucai.yifaqapp.model.network.entity.res.gendanBean;
import com.kucai.yifaqapp.util.OnItemClickListener;
import com.kucai.yifaqapp.widget.BubbleTextVew;
import com.kucai.yifaqapp.widget.GendanDialog;
import com.kucai.yifaqapp.widget.HongbaoDiolog;
import com.kucai.yifaqapp.widget.RoundImageView;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static com.kucai.yifaqapp.global.App.getContext;

/**
 * Created by admin on 2018/12/14.
 */

public class z_palnFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
        implements OnItemClickListener {
    Context mcontent;
    List<WebSocketMsgBean> data_one;
    int[] huiyuan = {R.mipmap.icon_member01, R.mipmap.icon_member02, R.mipmap.icon_member03, R.mipmap.icon_member04, R.mipmap.icon_member05, R.mipmap.icon_member06, R.mipmap.icon_member099};

    public z_palnFragmentAdapter(Context content, List<WebSocketMsgBean> dataone) {
        this.mcontent = content;
        this.data_one = dataone;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        switch (viewType) {
            case 2:
                return new MViewHolder1(LayoutInflater.from(mcontent)
                        .inflate(R.layout.msgleft, parent, false));
            case 4:
                return new MViewHolder(LayoutInflater.from(mcontent)
                        .inflate(R.layout.msgright, parent, false));
            case 22:
                return new MViewHolder5(LayoutInflater.from(mcontent)
                        .inflate(R.layout.msgleftimg, parent, false));
            case 44:
                return new MViewHolder6(LayoutInflater.from(mcontent)
                        .inflate(R.layout.msgrightimg, parent, false));
            case 8:
                return new MViewHolder3(LayoutInflater.from(mcontent)
                        .inflate(R.layout.msglefthongbao, parent, false));
            case 9:
                return new MViewHolder4(LayoutInflater.from(mcontent)
                        .inflate(R.layout.msglefthongbaoitem, parent, false));
            case 15:
                return new MViewHolder7(LayoutInflater.from(mcontent)
                        .inflate(R.layout.gengdanleft, parent, false));
        }
        return null;
    }

    @Override
    public int getItemViewType(int position) {
        if (data_one.get(position).status == 2) {
            return 2;
        } else if (data_one.get(position).status == 4) {
            return 4;
        } else if (data_one.get(position).status == 8) {
            return 8;
        } else if (data_one.get(position).status == 9) {
            return 9;
        } else if (data_one.get(position).status == 22) {
            return 22;
        } else if (data_one.get(position).status == 44) {
            return 44;
        } else if (data_one.get(position).status == 15) {
            return 15;
        } else {
            return 0;
        }
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, final int position) {
        try {
            if (viewHolder instanceof MViewHolder) {
                try {
                    MViewHolder holder = (MViewHolder) viewHolder;
                    String string = new String(Base64.decode(((String) data_one.get(position).msg).getBytes(), Base64.DEFAULT));
                    String text2 = java.net.URLDecoder.decode(string, "utf-8");
                    Pattern p_enter = Pattern.compile("</br>", Pattern.CASE_INSENSITIVE);//下面三行是将HTML中的换行符<br/>替换成"\n"
                    Matcher m_enter = p_enter.matcher(text2);
                    text2 = m_enter.replaceAll("\n");
                    holder.contentleft.setText(text2);
                    SimpleTarget<GlideDrawable> simpleTarget = new SimpleTarget<GlideDrawable>() {
                        @Override
                        public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                            holder.userimg.setImageDrawable(resource);
                        }
                    };
                    Glide.with(mcontent).load((HttpAdress.getuseAdress() + data_one.get(position).img))
                            .into(simpleTarget);
                    holder.huiyuan.setVisibility(View.VISIBLE);
                    switch (Integer.parseInt(data_one.get(position).level)) {
                        case 1:
                            Glide.with(mcontent).load(huiyuan[0]).asGif().into(holder.huiyuan);
                            break;
                        case 2:
                            Glide.with(mcontent).load(huiyuan[1]).asGif().into(holder.huiyuan);
                            break;
                        case 3:
                            Glide.with(mcontent).load(huiyuan[2]).asGif().into(holder.huiyuan);
                            break;
                        case 4:
                            Glide.with(mcontent).load(huiyuan[3]).asGif().into(holder.huiyuan);
                            break;
                        case 5:
                            Glide.with(mcontent).load(huiyuan[4]).asGif().into(holder.huiyuan);
                            break;
                        case 6:
                            Glide.with(mcontent).load(huiyuan[5]).asGif().into(holder.huiyuan);
                            break;
                        case 98:
                            Glide.with(mcontent).load(huiyuan[6]).asGif().into(holder.huiyuan);
                            break;
                        default:
                            holder.huiyuan.setVisibility(View.GONE);
                            break;
                    }
                    holder.username.setText((String) data_one.get(position).fd + "");
                    holder.usertime.setText((String) data_one.get(position).times);
                    holder.contentleft.setBackGroundColor(Color.parseColor("#" + (String) data_one.get(position).bg1));
                } catch (Exception e) {

                }
            } else if (viewHolder instanceof MViewHolder1) {
                try {
                    MViewHolder1 holder = (MViewHolder1) viewHolder;
                    String string = new String(Base64.decode(((String) data_one.get(position).msg).getBytes(), Base64.DEFAULT));
                    String text2 = java.net.URLDecoder.decode(string, "utf-8");
                    Pattern p_enter = Pattern.compile("</br>", Pattern.CASE_INSENSITIVE);//下面三行是将HTML中的换行符<br/>替换成"\n"
                    Matcher m_enter = p_enter.matcher(text2);
                    text2 = m_enter.replaceAll("\n");
                    holder.contentleft.setText(text2);
                    SimpleTarget<GlideDrawable> simpleTarget = new SimpleTarget<GlideDrawable>() {
                        @Override
                        public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                            holder.userimg.setImageDrawable(resource);
                        }
                    };
                    Glide.with(mcontent).load((HttpAdress.getuseAdress() + data_one.get(position).img))
                            .into(simpleTarget);
                    holder.huiyuan.setVisibility(View.VISIBLE);
                    switch (Integer.parseInt(data_one.get(position).level)) {
                        case 1:
                            Glide.with(mcontent).load(huiyuan[0]).asGif().into(holder.huiyuan);
                            break;
                        case 2:
                            Glide.with(mcontent).load(huiyuan[1]).asGif().into(holder.huiyuan);
                            break;
                        case 3:
                            Glide.with(mcontent).load(huiyuan[2]).asGif().into(holder.huiyuan);
                            break;
                        case 4:
                            Glide.with(mcontent).load(huiyuan[3]).asGif().into(holder.huiyuan);
                            break;
                        case 5:
                            Glide.with(mcontent).load(huiyuan[4]).asGif().into(holder.huiyuan);
                            break;
                        case 6:
                            Glide.with(mcontent).load(huiyuan[5]).asGif().into(holder.huiyuan);
                            break;
                        case 98:
                            Glide.with(mcontent).load(huiyuan[6]).asGif().into(holder.huiyuan);
                            break;
                        default:
                            holder.huiyuan.setVisibility(View.GONE);
                            break;
                    }
                    holder.username.setText((String) data_one.get(position).fd + "");
                    holder.usertime.setText((String) data_one.get(position).times);
                    holder.contentleft.setBackGroundColor(Color.parseColor("#" + (String) data_one.get(position).bg1));
                } catch (Exception e) {

                }
            } else if (viewHolder instanceof MViewHolder5) {
                try {
                    MViewHolder5 holder = (MViewHolder5) viewHolder;
                    String string = new String(Base64.decode(((String) data_one.get(position).msg).getBytes(), Base64.DEFAULT));
                    String text2 = java.net.URLDecoder.decode(string, "utf-8");
//                    Pattern p_enter = Pattern.compile("</br>", Pattern.CASE_INSENSITIVE);//下面三行是将HTML中的换行符<br/>替换成"\n"
//                    Matcher m_enter = p_enter.matcher(text2);
//                    text2 = m_enter.replaceAll("\n");
//                    holder.contentleft.setText(text2);
                    String finalstring = text2.substring(5);
                    String fina2string = finalstring.replace("&data=", "");
                    SimpleTarget<GlideDrawable> simpleTarget1 = new SimpleTarget<GlideDrawable>() {
                        @Override
                        public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                            holder.contentleft.setImageDrawable(resource);
                        }
                    };
                    Glide.with(mcontent).load((HttpAdress.getuseAdress() + fina2string))
                            .into(simpleTarget1);
                    SimpleTarget<GlideDrawable> simpleTarget = new SimpleTarget<GlideDrawable>() {
                        @Override
                        public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                            holder.userimg.setImageDrawable(resource);
                        }
                    };
                    Glide.with(mcontent).load((HttpAdress.getuseAdress() + data_one.get(position).img))
                            .into(simpleTarget);
                    holder.huiyuan.setVisibility(View.VISIBLE);
                    switch (Integer.parseInt(data_one.get(position).level)) {
                        case 1:
                            Glide.with(mcontent).load(huiyuan[0]).asGif().into(holder.huiyuan);
                            break;
                        case 2:
                            Glide.with(mcontent).load(huiyuan[1]).asGif().into(holder.huiyuan);
                            break;
                        case 3:
                            Glide.with(mcontent).load(huiyuan[2]).asGif().into(holder.huiyuan);
                            break;
                        case 4:
                            Glide.with(mcontent).load(huiyuan[3]).asGif().into(holder.huiyuan);
                            break;
                        case 5:
                            Glide.with(mcontent).load(huiyuan[4]).asGif().into(holder.huiyuan);
                            break;
                        case 6:
                            Glide.with(mcontent).load(huiyuan[5]).asGif().into(holder.huiyuan);
                            break;
                        case 98:
                            Glide.with(mcontent).load(huiyuan[6]).asGif().into(holder.huiyuan);
                            break;
                        default:
                            holder.huiyuan.setVisibility(View.GONE);
                            break;
                    }
                    holder.username.setText((String) data_one.get(position).fd + "");
                    holder.usertime.setText((String) data_one.get(position).times);
                } catch (Exception e) {

                }
            } else if (viewHolder instanceof MViewHolder6) {
                try {
                    MViewHolder6 holder = (MViewHolder6) viewHolder;
                    String string = new String(Base64.decode(((String) data_one.get(position).msg).getBytes(), Base64.DEFAULT));
                    String text2 = java.net.URLDecoder.decode(string, "utf-8");
//                    Pattern p_enter = Pattern.compile("</br>", Pattern.CASE_INSENSITIVE);//下面三行是将HTML中的换行符<br/>替换成"\n"
//                    Matcher m_enter = p_enter.matcher(text2);
//                    text2 = m_enter.replaceAll("\n");
//                    holder.contentleft.setText(text2);
                    String finalstring = text2.substring(5);
                    String fina2string = finalstring.replace("&data=", "");
                    SimpleTarget<GlideDrawable> simpleTarget1 = new SimpleTarget<GlideDrawable>() {
                        @Override
                        public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                            holder.contentleft.setImageDrawable(resource);
                        }
                    };
                    Glide.with(mcontent).load((HttpAdress.getuseAdress() + fina2string))
                            .into(simpleTarget1);
                    SimpleTarget<GlideDrawable> simpleTarget = new SimpleTarget<GlideDrawable>() {
                        @Override
                        public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                            holder.userimg.setImageDrawable(resource);
                        }
                    };
                    Glide.with(mcontent).load((HttpAdress.getuseAdress() + data_one.get(position).img))
                            .into(simpleTarget);
                    holder.huiyuan.setVisibility(View.VISIBLE);
                    switch (Integer.parseInt(data_one.get(position).level)) {
                        case 1:
                            Glide.with(mcontent).load(huiyuan[0]).asGif().into(holder.huiyuan);
                            break;
                        case 2:
                            Glide.with(mcontent).load(huiyuan[1]).asGif().into(holder.huiyuan);
                            break;
                        case 3:
                            Glide.with(mcontent).load(huiyuan[2]).asGif().into(holder.huiyuan);
                            break;
                        case 4:
                            Glide.with(mcontent).load(huiyuan[3]).asGif().into(holder.huiyuan);
                            break;
                        case 5:
                            Glide.with(mcontent).load(huiyuan[4]).asGif().into(holder.huiyuan);
                            break;
                        case 6:
                            Glide.with(mcontent).load(huiyuan[5]).asGif().into(holder.huiyuan);
                            break;
                        case 98:
                            Glide.with(mcontent).load(huiyuan[6]).asGif().into(holder.huiyuan);
                            break;
                        default:
                            holder.huiyuan.setVisibility(View.GONE);
                            break;
                    }
                    holder.username.setText((String) data_one.get(position).fd + "");
                    holder.usertime.setText((String) data_one.get(position).times);
                } catch (Exception e) {

                }
            } else if (viewHolder instanceof MViewHolder4) {
                try {
                    MViewHolder4 holder = (MViewHolder4) viewHolder;
                    holder.username.setText(data_one.get(position).fd + "");
                    holder.number.setText(data_one.get(position).msg + "");
                } catch (Exception e) {

                }
            } else if (viewHolder instanceof MViewHolder3) {
                try {
                    Intent intent = new Intent(mcontent, HongbaoDiolog.class);
                    intent.putExtra("id", data_one.get(position).msg + "");
                    mcontent.startActivity(intent);
                    MViewHolder3 holder = (MViewHolder3) viewHolder;
                    holder.item.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            //点击出现红包，再次点击，开始抢红包
                            //开始请求接口 抢红包
                            Intent intent = new Intent(mcontent, HongbaoDiolog.class);
                            intent.putExtra("id", data_one.get(position).msg + "");
                            mcontent.startActivity(intent);
                        }
                    });
                } catch (Exception e) {

                }
            } else if (viewHolder instanceof MViewHolder7) {
                //跟单
                MViewHolder7 holder = (MViewHolder7) viewHolder;
                //获取到单的数据
                String string = new String(Base64.decode(((String) data_one.get(position).dt).getBytes(), Base64.DEFAULT));
                String text2 = java.net.URLDecoder.decode(string, "utf-8");
                String string1 = new String(Base64.decode(((String) data_one.get(position).msg).getBytes(), Base64.DEFAULT));
                String text3 = java.net.URLDecoder.decode(string1, "utf-8");
                //获取到下单数据展示
                gendanBean bean = new Gson().fromJson(text2, gendanBean.class);
                holder.recycleviewlist.setLayoutManager(new LinearLayoutManager(mcontent));
                holder.gamenumber.setText("期号：" + bean.getIssue());
                Adapter adapter = new Adapter();
                adapter.setDatas(bean);
                if (bean.getPlayArr() != null) {
                    if (bean.getPlayArr().size() != 0) {
                        holder.recycleviewlist.setAdapter(adapter);
                    }
                }
                //获取到gameid
                switch (bean.getGameId()) {
                    case 80:
                        Glide.with(getContext()).load(R.mipmap.mssc).into(holder.gameimg);
                        holder.gamename.setText("秒速赛车");
                        break;
                    case 50:
                        Glide.with(getContext()).load(R.mipmap.bjsc).into(holder.gameimg);
                        holder.gamename.setText("北京赛车");
                        break;
                    case 82:
                        Glide.with(getContext()).load(R.mipmap.msft).into(holder.gameimg);
                        holder.gamename.setText("秒速飞艇");
                        break;
                    case 99:
                        Glide.with(getContext()).load(R.mipmap.xgpm).into(holder.gameimg);
                        holder.gamename.setText("香港跑马");
                        break;
                    case 70:
                        Glide.with(getContext()).load(R.mipmap.xglhc).into(holder.gameimg);
                        holder.gamename.setText("香港六合彩");
                        break;
                    case 81:
                        Glide.with(getContext()).load(R.mipmap.msssc).into(holder.gameimg);
                        holder.gamename.setText("秒速时时彩");
                        break;
                    case 1:
                        Glide.with(getContext()).load(R.mipmap.cqssc).into(holder.gameimg);
                        holder.gamename.setText("重庆时时彩");
                        break;
                    case 4:
                        Glide.with(getContext()).load(R.mipmap.xjssc).into(holder.gameimg);
                        holder.gamename.setText("新疆时时彩");
                        break;
                    case 60:
                        Glide.with(getContext()).load(R.mipmap.gdklsf).into(holder.gameimg);
                        holder.gamename.setText("广东快乐十分");
                        break;
                    case 91:
                        Glide.with(getContext()).load(R.mipmap.msnn).into(holder.gameimg);
                        holder.gamename.setText("秒速牛牛");
                        break;
                    case 90:
                        Glide.with(getContext()).load(R.mipmap.pksnn).into(holder.gameimg);
                        holder.gamename.setText("PK10牛牛");
                        break;
                    case 61:
                        Glide.with(getContext()).load(R.mipmap.cqxync).into(holder.gameimg);
                        holder.gamename.setText("重庆幸运农场");
                        break;
                    case 66:
                        Glide.with(getContext()).load(R.mipmap.pcdd).into(holder.gameimg);
                        holder.gamename.setText("PC蛋蛋");
                        break;
                    case 65:
                        Glide.with(getContext()).load(R.mipmap.bjklb).into(holder.gameimg);
                        holder.gamename.setText("北京快乐8");
                        break;
                    case 86:
                        Glide.with(getContext()).load(R.mipmap.msks).into(holder.gameimg);
                        holder.gamename.setText("秒速快三");
                        break;
                    case 85:
                        Glide.with(getContext()).load(R.mipmap.xylhc).into(holder.gameimg);
                        holder.gamename.setText("幸运六合彩");
                        break;
                    case 10:
                        Glide.with(getContext()).load(R.mipmap.jsks).into(holder.gameimg);
                        holder.gamename.setText("江苏快三");
                        break;
                    case 12:
                        Glide.with(getContext()).load(R.mipmap.gxks).into(holder.gameimg);
                        holder.gamename.setText("广西快三");
                        break;
                    case 13:
                        Glide.with(getContext()).load(R.mipmap.hubks).into(holder.gameimg);
                        holder.gamename.setText("湖北快三");
                        break;
                    case 11:
                        Glide.with(getContext()).load(R.mipmap.ahks).into(holder.gameimg);
                        holder.gamename.setText("安徽快三");
                        break;
                    case 16:
                        Glide.with(getContext()).load(R.mipmap.gsks).into(holder.gameimg);
                        holder.gamename.setText("甘肃快三");
                        break;
                    case 15:
                        Glide.with(getContext()).load(R.mipmap.hbks).into(holder.gameimg);
                        holder.gamename.setText("河北快三");
                        break;
                    case 18:
                        Glide.with(getContext()).load(R.mipmap.gzks).into(holder.gameimg);
                        holder.gamename.setText("贵州快三");
                        break;
                    case 21:
                        Glide.with(getContext()).load(R.mipmap.gdsyxw).into(holder.gameimg);
                        holder.gamename.setText("广东11选5");
                        break;
                    case 112:
                        Glide.with(getContext()).load(R.mipmap.txffc).into(holder.gameimg);
                        holder.gamename.setText("腾讯分分彩");
                        break;
                    case 113:
                        Glide.with(getContext()).load(R.mipmap.qqffc).into(holder.gameimg);
                        holder.gamename.setText("QQ分分彩");
                        break;
                    case 801:
                        Glide.with(getContext()).load(R.mipmap.qqffc).into(holder.gameimg);
                        holder.gamename.setText("快乐赛车");
                        break;
                    case 802:
                        Glide.with(getContext()).load(R.mipmap.qqffc).into(holder.gameimg);
                        holder.gamename.setText("快乐飞艇");
                        break;
                    case 803:
                        Glide.with(getContext()).load(R.mipmap.qqffc).into(holder.gameimg);
                        holder.gamename.setText("快乐时时彩");
                        break;
                        case 804:
                        Glide.with(getContext()).load(R.mipmap.twxyft).into(holder.gameimg);
                        holder.gamename.setText("台灣幸運飛艇");
                        break;
                    default:
                        holder.itemView.setVisibility(View.GONE);
                        break;

                }
                SimpleTarget<GlideDrawable> simpleTarget = new SimpleTarget<GlideDrawable>() {
                    @Override
                    public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                        holder.userimg.setImageDrawable(resource);
                    }
                };
                Glide.with(mcontent).load((HttpAdress.getuseAdress() + data_one.get(position).img))
                        .into(simpleTarget);
                holder.huiyuan.setVisibility(View.VISIBLE);

                //

                switch (Integer.parseInt(data_one.get(position).level)) {
                    case 1:
                        Glide.with(mcontent).load(huiyuan[0]).asGif().into(holder.huiyuan);
                        break;
                    case 2:
                        Glide.with(mcontent).load(huiyuan[1]).asGif().into(holder.huiyuan);
                        break;
                    case 3:
                        Glide.with(mcontent).load(huiyuan[2]).asGif().into(holder.huiyuan);
                        break;
                    case 4:
                        Glide.with(mcontent).load(huiyuan[3]).asGif().into(holder.huiyuan);
                        break;
                    case 5:
                        Glide.with(mcontent).load(huiyuan[4]).asGif().into(holder.huiyuan);
                        break;
                    case 6:
                        Glide.with(mcontent).load(huiyuan[5]).asGif().into(holder.huiyuan);
                        break;
                    case 98:
                        Glide.with(mcontent).load(huiyuan[6]).asGif().into(holder.huiyuan);
                        break;
                    default:
                        holder.huiyuan.setVisibility(View.GONE);
                        break;
                }
                holder.username.setText((String) data_one.get(position).fd + "");
                holder.usertime.setText((String) data_one.get(position).times);
                holder.conform.setClickable(false);
                holder.conform.setPressed(false);
                holder.conform.setEnabled(false);
                holder.recycleviewlist.setOnTouchListener(new View.OnTouchListener() {
                    @Override
                    public boolean onTouch(View v, MotionEvent event) {
                        if (event.getAction() == MotionEvent.ACTION_UP) {
                            Intent intent = new Intent(mcontent, GendanDialog.class);
                            intent.putExtra("gendaninfo", text2);
                            intent.putExtra("gendanConform", text3);
                            intent.putExtra("gendanUser", (String) data_one.get(position).fd + "");
                            mcontent.startActivity(intent);
                        }
                        return false;
                    }
                });
                holder.xiazhuinfo.setText("共 " + bean.getTotalNums() + "注， 共 " + bean.getTotalMoney() + "元");
                holder.clickitem.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(mcontent, GendanDialog.class);
                        intent.putExtra("gendaninfo", text2);
                        intent.putExtra("gendanConform", text3);
                        intent.putExtra("gendanUser", (String) data_one.get(position).fd + "");
                        mcontent.startActivity(intent);
                    }
                });
            }
        } catch (Exception e) {

        }
    }

    @Override
    public int getItemCount() {
        if (data_one == null) {
            return 0;
        } else {
            if (data_one.size() == 0) {
                return 0;
            } else {
                return data_one.size();
            }
        }
    }


    @Override
    public void onItemClick(View view, int position) {

    }

    class MViewHolder extends RecyclerView.ViewHolder {
        BubbleTextVew contentleft;
        RoundImageView userimg;
        TextView username;
        TextView usertime;
        ImageView huiyuan;

        MViewHolder(View itemView) {
            super(itemView);
            contentleft = itemView.findViewById(R.id.contentleft);
            userimg = itemView.findViewById(R.id.userimg);
            username = itemView.findViewById(R.id.username);
            usertime = itemView.findViewById(R.id.usertime);
            huiyuan = itemView.findViewById(R.id.huiyuan);
        }
    }

    class MViewHolder1 extends RecyclerView.ViewHolder {
        BubbleTextVew contentleft;
        RoundImageView userimg;
        TextView username;
        TextView usertime;
        ImageView huiyuan;

        MViewHolder1(View itemView) {
            super(itemView);
            contentleft = itemView.findViewById(R.id.contentleft);
            userimg = itemView.findViewById(R.id.userimg);
            username = itemView.findViewById(R.id.username);
            usertime = itemView.findViewById(R.id.usertime);
            huiyuan = itemView.findViewById(R.id.huiyuan);
        }
    }

    class MViewHolder3 extends RecyclerView.ViewHolder {
        RelativeLayout item;

        MViewHolder3(View itemView) {
            super(itemView);
            item = itemView.findViewById(R.id.item);
        }
    }

    class MViewHolder4 extends RecyclerView.ViewHolder {
        TextView username;
        TextView number;

        MViewHolder4(View itemView) {
            super(itemView);
            username = itemView.findViewById(R.id.username);
            number = itemView.findViewById(R.id.number);
        }
    }

    class MViewHolder5 extends RecyclerView.ViewHolder {
        ImageView contentleft;
        RoundImageView userimg;
        TextView username;
        TextView usertime;
        ImageView huiyuan;

        MViewHolder5(View itemView) {
            super(itemView);
            contentleft = itemView.findViewById(R.id.contentleft);
            userimg = itemView.findViewById(R.id.userimg);
            username = itemView.findViewById(R.id.username);
            usertime = itemView.findViewById(R.id.usertime);
            huiyuan = itemView.findViewById(R.id.huiyuan);
        }
    }

    class MViewHolder6 extends RecyclerView.ViewHolder {
        ImageView contentleft;
        RoundImageView userimg;
        TextView username;
        TextView usertime;
        ImageView huiyuan;

        MViewHolder6(View itemView) {
            super(itemView);
            contentleft = itemView.findViewById(R.id.contentleft);
            userimg = itemView.findViewById(R.id.userimg);
            username = itemView.findViewById(R.id.username);
            usertime = itemView.findViewById(R.id.usertime);
            huiyuan = itemView.findViewById(R.id.huiyuan);
        }
    }

    class MViewHolder7 extends RecyclerView.ViewHolder {
        RoundImageView userimg;
        TextView username;
        TextView usertime;
        ImageView huiyuan;
        ImageView gameimg;
        TextView gamename;
        TextView gamenumber;
        TextView gameplay;
        Button conform;
        RecyclerView recycleviewlist;
        LinearLayout clickitem;
        TextView xiazhuinfo;

        MViewHolder7(View itemView) {
            super(itemView);
            userimg = itemView.findViewById(R.id.userimg);
            username = itemView.findViewById(R.id.username);
            usertime = itemView.findViewById(R.id.usertime);
            huiyuan = itemView.findViewById(R.id.huiyuan);
            gameimg = itemView.findViewById(R.id.gameimg);
            gamename = itemView.findViewById(R.id.gamename);
            gamenumber = itemView.findViewById(R.id.gamenumber);
            gameplay = itemView.findViewById(R.id.gameplay);
            conform = itemView.findViewById(R.id.conform);
            recycleviewlist = itemView.findViewById(R.id.recycleviewlist);
            clickitem = itemView.findViewById(R.id.clickitem);
            xiazhuinfo = itemView.findViewById(R.id.xiazhuinfo);
        }
    }


    class Adapter extends RecyclerView.Adapter<Adapter.MViewHolder>
            implements OnItemClickListener {
        private gendanBean mbeans;

        @Override
        public MViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            return new MViewHolder(LayoutInflater.from(getContext())
                    .inflate(R.layout.gengdanitem, parent, false));
        }

        public void setDatas(gendanBean beans) {
            this.mbeans = beans;
        }

        @Override
        public void onBindViewHolder(final MViewHolder holder, final int position) {
            holder.text1.setText(mbeans.getPlayArr().get(position).getPlayName() + "");
            holder.text2.setText(mbeans.getPlayArr().get(position).getBetBean_money() + "");
        }

        @Override
        public int getItemCount() {
            return mbeans.getPlayArr().size();
        }

        @Override
        public void onItemClick(View view, int position) {

        }

        class MViewHolder extends RecyclerView.ViewHolder {
            TextView text1;
            TextView text2;

            MViewHolder(View itemView) {
                super(itemView);
                text1 = itemView.findViewById(R.id.text1);
                text2 = itemView.findViewById(R.id.text2);
            }
        }
    }


}
